package com.burstly.lib.util;

import android.util.Log;
import com.burstly.lib.BurstlySdk;
import com.burstly.lib.constants.Constants;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public final class LoggerExt
{
  public static final int DEBUG_LEVEL = 3;
  public static final int ERROR_LEVEL = 6;
  public static final int INFO_LEVEL = 4;
  private static final LoggerExt INSTANCE = new LoggerExt();
  private static final Map<Integer, String> LOG_LEVEL_NAMES;
  public static final int NONE_LEVEL = 7;
  private static final String SDK_VERSION;
  private static final String TAG = "Logger";
  public static final int WARN_LEVEL = 5;
  private static int sLogLevel = 3;

  static
  {
    SDK_VERSION = "Burstly SDK v." + Constants.SDK_VERSION;
    LOG_LEVEL_NAMES = new HashMap(10);
    LOG_LEVEL_NAMES.put(Integer.valueOf(7), "Logger.NONE_LEVEL");
    LOG_LEVEL_NAMES.put(Integer.valueOf(3), "Logger.DEBUG_LEVEL");
    LOG_LEVEL_NAMES.put(Integer.valueOf(4), "Logger.INFO_LEVEL");
    LOG_LEVEL_NAMES.put(Integer.valueOf(5), "Logger.WARN_LEVEL");
    LOG_LEVEL_NAMES.put(Integer.valueOf(6), "Logger.ERROR_LEVEL");
  }

  private static int checkLogLevel(int paramInt)
  {
    if ((paramInt > 7) || (paramInt < 3))
    {
      Log.w("Logger", "Provided log level " + paramInt + " is not NONE_LEVEL, DEBUG_LEVEL, INFO_LEVEL, WARN_LEVEL or ERROR_LEVEL. Skipped invalid log level. Log level has been set to WARN_LEVEL.");
      paramInt = 5;
    }
    return paramInt;
  }

  private static boolean fitsLogLevel(int paramInt)
  {
    return paramInt >= sLogLevel;
  }

  public static LoggerExt getInstance()
  {
    return INSTANCE;
  }

  public static int getLogLevel()
  {
    return sLogLevel;
  }

  private String log(int paramInt, String paramString1, String paramString2, Object[] paramArrayOfObject)
  {
    Object localObject = "";
    String str2;
    String str3;
    if ((paramString2 != null) && (fitsLogLevel(paramInt)))
    {
      String str1 = paramString2;
      if (paramArrayOfObject.length != 0)
      {
        str1 = MessageFormat.format(paramString2, paramArrayOfObject);
        localObject = str1;
      }
      str2 = new SimpleDateFormat("dd-MM-yy HH:mm:ss:SSS").format(new Date()) + " " + str1;
      str3 = SDK_VERSION + " " + paramString1;
    }
    switch (paramInt)
    {
    default:
      Log.e(str3, str2);
      return localObject;
    case 3:
      Log.d(str3, str2);
      return localObject;
    case 4:
      Log.i(str3, str2);
      return localObject;
    case 5:
    }
    Log.w(str3, str2);
    return localObject;
  }

  public static void setLogLevel(int paramInt)
  {
    sLogLevel = checkLogLevel(paramInt);
    Log.i("Logger", "Log level has been set to " + (String)LOG_LEVEL_NAMES.get(Integer.valueOf(sLogLevel)));
  }

  public String logDebug(String paramString1, String paramString2, Object[] paramArrayOfObject)
  {
    return log(3, paramString1, paramString2, paramArrayOfObject);
  }

  public String logError(String paramString1, String paramString2, Object[] paramArrayOfObject)
  {
    return log(6, paramString1, paramString2, paramArrayOfObject);
  }

  public String logInfo(String paramString1, String paramString2, Object[] paramArrayOfObject)
  {
    return log(4, paramString1, paramString2, paramArrayOfObject);
  }

  public void logThrowable(String paramString, Throwable paramThrowable)
  {
    Utils.addInStackTrace(paramThrowable, "BurstlySDK=" + BurstlySdk.getSdkVersion() + "-" + Constants.BUILD_ID);
    logError(paramString, Log.getStackTraceString(paramThrowable), new Object[0]);
  }

  public String logWarning(String paramString1, String paramString2, Object[] paramArrayOfObject)
  {
    return log(5, paramString1, paramString2, paramArrayOfObject);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.util.LoggerExt
 * JD-Core Version:    0.6.2
 */